package edu.zut.hb.software.teach.echo.web.spring.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import edu.zut.hb.software.teach.echo.domain.EchoMessage;
import edu.zut.hb.software.teach.echo.service.EchoManager;
import edu.zut.hb.software.teach.echo.service.impl.EchoManagerImpl;

@Controller
@RequestMapping("/echo")
public class EchoController {

	EchoManager echoManager = new EchoManagerImpl();

	@RequestMapping(value = "{message}", method = RequestMethod.GET)
	public @ResponseBody EchoMessage echo(@PathVariable String message) {
		EchoMessage echoMessage = new EchoMessage();
		echoMessage.setId(1L);
		echoMessage.setText(message);
		EchoMessage response = this.echoManager.echoMessage(echoMessage);
		return response;
	}
}
